package bb.lanxing.device.sgdevcie.xpair.net

import bb.lanxing.device.sgdevcie.xpair.uimodel.XPairDeviceBoundParam
import bb.lanxing.device.sgdevcie.xpair.uimodel.XossBoundedDevice
import bb.lanxing.net.retrofit.GenericResponse
import bb.lanxing.net.retrofit.XossRetrofitApiClient
import retrofit2.Response

class XPairRepository private constructor() {
    private val mService by lazy {
        XossRetrofitApiClient.getInstance().create(
            XPairService::class.java
        )
    }

    suspend fun boundDevice(
        xPairDeviceBoundParam: XPairDeviceBoundParam
    ): Response<String> {
        return mService.boundDevice(xPairDeviceBoundParam)
    }

    suspend fun unBoundDevice(
        xPairDeviceBoundParam: XPairDeviceBoundParam
    ): Response<String> {
        return mService.unboundDevice(xPairDeviceBoundParam)
    }

    suspend fun boundedList(): GenericResponse<MutableList<XossBoundedDevice>> {
        return mService.boundedList()
    }

    companion object {
        @Volatile
        private var instance: XPairRepository? = null
        fun getInstance() = instance ?: synchronized(this) { instance ?: XPairRepository() }
    }
}
